package com.subaiwang.service.officialWebsite;

import com.github.pagehelper.PageHelper;
import com.subaiwang.dao.official.OfficialWebsiteMapper;
import com.subaiwang.pojo.OfficialContent;
import com.subaiwang.pojo.OfficialWebsite;
import com.subaiwang.pojo.Pages;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("officialWebsiteService")
public class OfficialWebsiteServiceImpl implements OfficialWebsiteService{
    @Resource
    private OfficialWebsiteMapper officialWebsiteMapper;
    @Override
    public List<OfficialWebsite> getOfficialWebsite(String type, String name, int pageNo, int pageSize) {

        return officialWebsiteMapper.getOfficialWebsite(type, name, ((pageNo-1)*pageSize), pageSize);
    }

    @Override
    public List<OfficialWebsite> getOfficialWebsite2() {
        return officialWebsiteMapper.getOfficialWebsite2();
    }

    @Override
    public void getPageList(String typeWebsite, String name, Pages pages) {
       List<OfficialWebsite> list=officialWebsiteMapper.getOfficialWebsite(typeWebsite, name, ((pages.getPageNo()-1)*pages.getPageSize()), pages.getPageSize());
        pages.setOfficialWebsitesList(list);
    }

    @Override
    public int getCount(String typeWebsite,String name) {
        return officialWebsiteMapper.getCount(typeWebsite,name);
    }

    @Override
    public void getOfficialContent(String content,Pages pages) {
        List<OfficialContent> list=officialWebsiteMapper.getOfficialContent( content, ((pages.getPageNo()-1)*pages.getPageSize()), pages.getPageSize());
        pages.setOfficialContentList(list);
    }

    @Override
    public int getCount2(String content) {
        return officialWebsiteMapper.getCount2(content);
    }

    @Override
    public boolean addContent(OfficialContent officialContent) {
        boolean flag=false;
        int count=officialWebsiteMapper.addContent(officialContent);
        if (count>0){
            flag=true;
        }
        return flag;
    }


}
